# 作者：小七
# 2025年01月05日
import os


def seek_start():
    file = open('file1', 'r', encoding='utf-8')
    file.seek(4, os.SEEK_SET)
    text = file.read(5)
    print(text)
    file.close()


def seek_end():
    file = open('file1', 'r', encoding='utf-8')
    file.seek(0, os.SEEK_END)
    text = file.read(5)
    print(text)
    file.close()


def seek_cur():
    file = open('file1', 'r', encoding='utf-8')
    file.seek(0, os.SEEK_CUR)
    text = file.read(5)
    print(text)
    file.close()


def seek_b_cur():
    file = open('file1', 'rb+')
    file.seek(4, os.SEEK_CUR)
    file.seek(-3, os.SEEK_END)
    b = file.read()
    print(b)
    file.close()


def copy_file():
    file1 = open("boqi.PNG", 'rb+')
    file2 = open("boqi_copy.PNG", 'wb')
    b = file1.read()
    file2.write(b)
    file1.close()
    file2.close()


if __name__ == "__main__":
    # seek_start()
    # seek_end()
    # seek_cur()
    # seek_b_cur()
    copy_file()
